package com.ujn.zhxy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ujn.zhxy.mapper.AdminMapper;
import com.ujn.zhxy.mapper.ClazzMapper;
import com.ujn.zhxy.pojo.Admin;
import com.ujn.zhxy.pojo.Clazz;
import com.ujn.zhxy.pojo.Grade;
import com.ujn.zhxy.service.AdminService;
import com.ujn.zhxy.service.ClazzService;
import com.ujn.zhxy.util.Result;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("clazzServiceImpl") //括号内为id
@Transactional //事务控制
public class ClazzServiceImpl extends ServiceImpl<ClazzMapper, Clazz> implements ClazzService {
    @Override
    public IPage<Clazz> getClazzByOpr(Page<Clazz> page, String gradeName, String name) {
        QueryWrapper<Clazz> queryWrapper = new QueryWrapper();

        if(gradeName != null){
            queryWrapper.eq("grade_name",gradeName);
        }
        if(name != null){
            queryWrapper.like("name",name);
        }

        queryWrapper.orderByDesc("id");
        Page<Clazz> page1 = baseMapper.selectPage(page, queryWrapper);
        return page1;

    }

    @Override
    public List<Clazz> getClazzs() {
        List<Clazz> list = baseMapper.selectList(null);
        return list;
    }


    //ServiceImpl<M,T>包含了针对于IService的实现
}
